import { defHttp } from '/@/utils/http/axios';

enum Api {
  GetCategoryList = '/book/category',
  GetBookList = '/book/list',
  CreateBook = '/book',
  DeleteBook = '/book',
  CreateContents = '/contents'
}

export const getCategoryList = () => {
  return defHttp.get({ url: Api.GetCategoryList });
};

export const getBookList = (params) => {
  return defHttp.get({ url: Api.GetBookList, params });
};

export const createBook = (data) => {
  return defHttp.post({ url: Api.CreateBook, data }, { successMessageMode: 'message', errorMessageMode: 'none'});
};

export const deleteBook = (id) => {
  return defHttp.delete({ url: Api.DeleteBook + `/${id}` }, { successMessageMode: 'message'});
};

export const createContents = (data) => {
  return defHttp.post({ url: Api.CreateContents, data }, { successMessageMode: 'message'});
};
